<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
	<title>
	<?php if(!empty($pagetitle)): echo ($pagetitle); endif; ?>
</title>
<script type="text/javascript" src="__ROOT__/public/jsLib/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="__ROOT__/public/jsLib/jquery.cookies.2.2.0.min.js"></script>
<script type="text/javascript" src="__ROOT__/asset/js/main.js"></script>
<script type="text/javascript" src="__ROOT__/asset/js/checkfield.js"></script>
<link rel="stylesheet" type="text/css" href="__ROOT__/public/jsLib/bootstrap/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="__ROOT__/public/jsLib/bootstrap/google-code-prettify/prettify.css" />
<link rel="stylesheet" type="text/css" href="__ROOT__/asset/main.css" />
<script type="text/javascript" src="__ROOT__/public/jsLib/bootstrap/bootstrap.min.js"></script>
<script type="text/javascript" src="__ROOT__/public/jsLib/bootstrap/google-code-prettify/prettify.js"></script>
<script type="text/javascript">
	var APP = "__APP__";
	var cookie_prefix = '<?php echo ($cookie_prefix); ?>';
	var app_path = $.cookies.get(cookie_prefix+'config_path');
	var dir = $.cookies.get(cookie_prefix+'base_dir');
	var app_name = $.cookies.get(cookie_prefix+'app_name');
	var version = $.cookies.get(cookie_prefix+'version');
	var app_url=$.cookies.get(cookie_prefix+'app_url');
	$(function () {
		//首页的tooltip绑定
		$('.leftbar>li').tooltip({placement:'right'});
		prettyPrint()
	});
</script>
	<script type="text/javascript">
		function changeflag(obj) {
			if (obj.value == 'preg_match') {
				$('#flag').html('<option value="">无</option><option value="256">PREG_OFFSET_CAPTURE</option>');
				$('#replacement').css('display', 'none');
			} else if (obj.value == 'preg_match_all') {
				$('#flag').html('<option value="">无</option><option value="256">PREG_OFFSET_CAPTURE</option><option value="2">PREG_SET_ORDER</option>');
				$('#replacement').css('display', 'none');
			} else {
				$('#replacement').css('display', 'block');
			}
		}
		function pregtest() {
			$.post("__APP__/Tool/pregTest", {
				pattern    :$('#pattern').val(),
				strinput   :$('#strinput').val(),
				preg_func  :$('#preg_func').val(),
				replacement:$('#replacement').val(),
				flag       :$('#flag').val()
			}, function (data, stauts) {
				if (stauts == 'success') {
					$('#preg_return').val(data)
				}
			})
		}

		$(function(){
			$('#help').popover({
				placement:'top',
				trigger:'click',
				title:'正则表达式',
				content:'应输入完整的PHP正则表达式,包括边界符号。\n输入的正则表达式将以单引号字符串作为函数的$pattern参数。'
			})
		})
	</script>
	<style type="text/css">
		.pcre textarea{
			width: 686px;;
			font-family: monospace;
		}


		#replacement {
			display: none;
		}

	</style>
</head>
<body>
<div class="navbar navbar-fixed-top navbar-inverse">
	<div class="navbar-inner">
		<div class="container">
			<a class="brand" href="__APP__" data-original-title="返回TP助手首页">ThinkPHP助手</a>
			<ul class="nav">
				<li class="divider-vertical"></li>

				<li><a href="" class="app_name" data-original-title="访问项目首页" style="color: #ffffff;font-weight: bold;" target="_blank"></a></li>
			</ul>

			<form class="pull-right" id="docform" action="" method="post" enctype="application/x-www-form-urlencoded" target="_blank">
				<div class="input-prepend input-append">
					<select name="docname" id="docname" class="" onchange="getAction()">
						<option value="php">php</option>
						<option value="jquery">jQuery</option>
						<option value="thinkphp">ThinkPHP</option>
					</select>
					<input name="pattern" class="span2" id="appendedInputButtons" type="text" onchange="getAction()" placeholder="输入函数名或关键词">
					<input type="hidden" name="keywords" value="">
					<input type="hidden" name="show" value="quickref">
					<input type="hidden" name="lang" value="zh">
					<button class="btn" type="submit">搜索</button>
				</div>
			</form>

		</div>
	</div>
</div>

<div class="top-alert alert-error affix" style="display: none;">
	<div class="container ">
		<button class="close" style="margin-top: 4px;">&times;</button>
		<div class="alert alert-error alert-noborder alert-content" style="">
			表单填写有误,请检查红色提示表单项.
		</div>
	</div>
</div>

<script type="text/javascript">
	$('.navbar .app_name').text("当前项目：" + app_name);
	$('.navbar .app_name').attr('href', app_url);
	$('.navbar a').tooltip({placement:'bottom'});
	var search = {
		php     :"http://cn2.php.net/search.php",
		jquery  :'http://api.jquery.com/?ns0=1&s=keywords',
		thinkphp:'http://doc.thinkphp.cn/manual/_search.html'
	}
	function getAction() {
		var keyword = $("input[name='pattern']").val();
		var url = search[$('#docname').val()].replace(/keywords/, keyword);
		$('#docform').attr('action', url);
		$("input[name='keywords']").val(keyword)
	}
	getAction();
</script>
<div class="container content" >
	<div class="row body-content">
		<div class="span3">
			<ul class="nav nav-tabs nav-stacked leftbar">
	<li id="config_list" data-original-title="修改当前项目的配置文件">
		<a href="__APP__/Config/index">
			编辑项目配置
			<i class="icon-chevron-right"></i>
		</a>
	</li>
	<li data-original-title="快速向项目中添加常用js库">
		<a href="__APP__/FileManager/getfilelist" id="addlib" class="showform" data-original-title="添加js或css框架到项目目录">添加前端库
		<i class="icon-chevron-right"></i>
		</a>
	</li>
	<li>
		<a href="__APP__/Index/pregTest" id="pcrehelper" class="showform" data-original-title="正则表达式测试">PHP正则助手
		<i class="icon-chevron-right"></i>
		</a>
	</li>
	<li>
		<a href="__APP__/Index/fragmentTest">代码片段测试
		<i class="icon-chevron-right"></i>
		</a>
	</li>
	<li>
		<a href="__APP__/Index/installConsole">安装Console工具
			<i class="icon-chevron-right"></i>
		</a>
	</li>
	<li>
		<a href="__APP__/Index/markdown">Markdown编辑器
			<i class="icon-chevron-right"></i>
		</a>
	</li>
</ul>
<script type="text/javascript">
	$.each($('.leftbar li'),function(){
		if (location.href.indexOf($(this).find('a').attr('href'))>0 ) {
			$(this).addClass('active')
		}
	})
</script>

		</div>
		<div class="span9 pcre" >
			<div>
				<textarea name="strinput" id="strinput" cols="30" rows="3">"hello world"是每个程序员的初恋...</textarea><br />
				<textarea name="pattern" id="pattern" rows="2" >/hello world/</textarea><br />

				<div class="form-inline" style="margin-bottom: 10px;">
					<label for="preg_func">函数</label>
					<select name="preg_func" id="preg_func" onchange="changeflag(this)">
						<option value="preg_match">preg_match</option>
						<option value="preg_match_all">preg_match_all</option>
						<option value="preg_replace">preg_replace</option>
					</select>

					<label for="flag">flag</label>
					<select name="flag" id="flag">
						<option value="">无</option>
						<option value="256">PREG_OFFSET_CAPTURE</option>
					</select>
					<input type="button" value="测试" class="btn btn-primary" onclick="pregtest()">
					<input type="button" value="帮助" id="help" class="btn btn-primary" data-toggle="button">
					<a href="http://cn2.php.net/manual/zh/ref.pcre.php" class="btn btn-primary" target="_blank">文档</a>
				</div>
				<textarea id="replacement">输入要替换的内容</textarea>
				<textarea name="preg_return" id="preg_return" rows="10" readonly></textarea>
				<div class="alert alert-success">
					<h5>语法摘要</h5>
					分组：捕获()、非捕获(?:)、注释(?#)<br/>
					分组命名：(?&lt;name&gt;)、(?'name')、(?P&lt;name&gt;)<br/>
					环视结构：(?=)(?!)(?&lt;=)(?&lt;!)<br/>
					条件选择：(?(后向引用或环视结构)Pattern|elsePattern)<br/>
					模式修饰：i大小写不敏感，m多行模式，U非贪婪模式，s点通配模式，A锚定模式<br/>
					\G断言在指定了$offset参数的 preg_match()调用中匹配搜索的起始位置<br/>
					\xhh 16进制编码字符<br/>
					理解贪婪匹配： 用 ^.*([0-9]+)  来匹配  copyright 2003!  括号会捕获到什么？
				</div>
			</div>
		</div>
	</div>
</div>
<?php echo ($footer); ?>
</body>
</html>